﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class System_AddRole : ATPages
{
    ZSql info = new ZSql();
    Function f = new Function();
    protected void Page_Load(object sender, EventArgs e)
    {
        lblMsg.Text = "";

        if (!IsPostBack)
        {
            lblPath.Text = f.getModuleidAdd(Request["moduid"]);
            if (!string.IsNullOrEmpty(Request["rid"].ToString()))
            {
                InitInfo();
            }
        }
    }


    private void InitInfo()
    {
        string roleid = Request["rid"].ToString();

        txtRole.Text = info.GetScalar("select role from role where roleid = " + roleid).ToString();

        info.Close();
    }


  


    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (txtRole.Text.Trim() == "")
        {
            lblMsg.Text = "请填写角色名称";
            return;
        }

        if (string.IsNullOrEmpty(Request["rid"]))
        {
            info.Open("insert into role values('" + Common.FormatParameter(txtRole.Text) + "')");
        }
        else
        {
            info.Open("update role set role = '" + Common.FormatParameter(txtRole.Text) + "' where roleid = " + Request["rid"].ToString());
        }

        info.Close();

        Response.Redirect("Role.aspx?moduid="+Request["moduid"]);
    }
}
